package P105_ForNameForArray;

import org.junit.Test;

import java.lang.reflect.Array;

/**
 * 动态加载不适合数组
 */
public class ForNameForArray {

    @Test
    public void Test() throws ClassNotFoundException {
        String[] strings = new String[10];
        System.out.println(strings.toString());
        Class.forName("java.lang.String[]");
    }

    @Test
    public void Test2() throws ClassNotFoundException {
        Class.forName("[Ljava.lang.String;");
        Class.forName("[B");
        Class.forName("[C");
        Class.forName("[D");
        Class.forName("[F");
        Class.forName("[I");
        Class.forName("[J");
        Class.forName("[S");
        Class.forName("[Z");
        //动态创建数组
        String[] strings = (String[]) Array.newInstance(String.class, 10);
        //多维数组
        int[][] ints = (int[][]) Array.newInstance(int.class,  2, 3);
    }
}
